const state = {
    result: {}
}
const actions = {
    save_expert: ({ commit }, payload) => {
        commit('SAVEEXPERT', payload)
    },
    add_expert: ({ commit }, payload) => {
        commit('ADDEXPERT', payload)
    },
    put_expert: ({ commit }, payload) => {
        commit('PUTEXPERT', payload)
    },
    del_expert: ({ commit }, payload) => {
        commit('DELEXPERT', payload)
    }
}
const mutations = {
    SAVEEXPERT: (state, payload) => {
        state.result = payload.result
    },
    ADDEXPERT: (state, payload) => {
        state.result.content.push(payload)
    },
    PUTEXPERT: (state, payload) => {
        let expert = state.result.content
        let index = expert.findIndex(it => it.id === payload.id)
        expert.splice(index, 1, payload)
    },
    DELEXPERT: (state, payload) => {
        let expert = state.result.content
        let index = expert.findIndex(it => it.id === payload.id)
        expert.splice(index, 1)
    }
}
const getters = {
    getExpert: state => state.result
}
export default {
    state,
    getters,
    actions,
    mutations
}